package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;

public class FileProcess {

	public static final String path = "E:\\test\\ActWeekTitle.txt";
	
	public static void main(String[] args) {
		try {
			File file = new File(path);
			if (!file.exists()) {
				System.out.println("file err");
				return;
			}
			Map<Integer, Map<Long, Integer>> map = new HashMap<Integer, Map<Long,Integer>>();
			BufferedReader br = new BufferedReader(new FileReader(file));
			String str = null;
			int[] titleCount = new int[4];
			int totalUser = 0;
			while ((str = br.readLine()) != null) {
				String[] data = str.split("-");
				String[] users = data[1].split(",");
//				totalUser += users.length;
				int area = Integer.parseInt(data[0]);
				if (!map.containsKey(area)) {
					map.put(area, new HashMap<Long, Integer>());
				}
				int[] posSign = new int[3];
				for (String e : users) {
					String[] one = e.split(":");
					long uid = Long.parseLong(one[0]);
					int score = Integer.parseInt(one[1]);
					map.get(area).put(uid, score);
					if (score >= 80000 && posSign[0] <= 0) {
						posSign[0]++;
						titleCount[0]++;
					} else if (score < 80000 && score >= 30000 && posSign[1] <= 0) {
						posSign[1]++;
						titleCount[1]++;
					} else if (score < 30000 && score >= 3000 && posSign[2] <= 0) {
						posSign[2]++;
						titleCount[2]++;
					} else {
						titleCount[3]++;
					}
				}
				System.out.println(str);
			}
			for (int i = 0; i < titleCount.length; i++) {
				
				System.out.print(titleCount[i] + ",");
			}
			
			for (Map<Long, Integer> e : map.values()) {
				totalUser += e.size();
			}
			System.out.println(totalUser);
			br.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			
		}
	}
}
